package com.dnjn.happiness.score.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.dnjn.happiness.common.core.constant.HappyConstants;
import com.dnjn.happiness.common.core.constant.SecurityConstants;
import com.dnjn.happiness.common.core.domain.R;
import com.dnjn.happiness.common.core.exception.base.BaseException;
import com.dnjn.happiness.common.core.utils.StringUtils;
import com.dnjn.happiness.common.core.web.domain.AjaxResult;
import com.dnjn.happiness.emo.api.RemoteEmoUserService;
import com.dnjn.happiness.emo.api.RemoteRiskService;
import com.dnjn.happiness.emo.api.RemoteUserModelScoreService;
import com.dnjn.happiness.emo.api.domain.UserModelScore;
import com.dnjn.happiness.emo.api.model.EmoUserVO;
import com.dnjn.happiness.common.core.score.vo.HappyAdvice;
import com.dnjn.happiness.common.core.score.vo.HappyAiType;
import com.dnjn.happiness.common.core.score.vo.HappyApprise;
import com.dnjn.happiness.common.core.score.dto.HappyDTO;
import com.dnjn.happiness.common.core.score.vo.HappySurvey;
import com.dnjn.happiness.common.core.score.vo.HappyTraining;
import com.dnjn.happiness.common.core.score.vo.HappyVO;
import com.dnjn.happiness.emo.api.model.RiskVO;
import com.dnjn.happiness.common.core.score.dto.UserModelScoreVO;
import com.dnjn.happiness.score.config.CoefficientConfig;
import com.dnjn.happiness.score.enums.AdviceEnum;
import com.dnjn.happiness.score.enums.AiEnum;
import com.dnjn.happiness.score.enums.AppriseEnum;
import com.dnjn.happiness.score.service.IHScoresService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;


@Service
public class HScoresServiceImpl implements IHScoresService {

    @Autowired
    private CoefficientConfig config;


    @Autowired
    private RemoteUserModelScoreService userModelScoreService;


    @Autowired
    private RemoteEmoUserService emoUserService;


    @Autowired
    private RemoteRiskService riskService;

    @Autowired
    private IHScoresService hScoresService;

    @Override
    @Transactional
    public HappyDTO getHappinessScores(HappyVO vo) throws Exception {

        HappyDTO happyDTO = new HappyDTO();

        happyDTO.setUserId(vo.getUserId());
        UserModelScoreVO userModelScore = null;

        getRisk(vo);

        //计算Ai----------

        if (ObjectUtil.isNotNull(vo.getAi())) {
            userModelScore = getAiModelScore(vo);
        }
        // -----------------------计算评价 -----------------------------------------------------------------------

        if (ObjectUtil.isNotNull(vo.getApprise())) {
            userModelScore = getAppriseModelModel(vo);
        }
        //----------------------------------------计算问卷--------------------------------
        if (ObjectUtil.isNotNull(vo.getSurvey())) {
            userModelScore = getSurveyModelScore(vo);
        }

        //---------------------------------------计算培训------------------------------------------------
        if (ObjectUtil.isNotNull(vo.getTraining())) {
            userModelScore = getTrainingModelScore(vo);
        }
        //---------------------------------------计算建议------------------------------------------------
        if (ObjectUtil.isNotNull(vo.getAdvice())) {
            userModelScore = getAdviceModelScore(vo);
        }
        //------------------------------------commuination 沟通------------------------------------------------------
        Double communicateModelScore = 0.0;
        if (ObjectUtil.isNotNull(vo.getCommunicate())) {
            communicateModelScore = getCommunicateModelScore(vo);
//            R<EmoUserVO> infoByUserId = emoUserService.getInfoByUserId(vo.getUserId(), SecurityConstants.INNER);
            EmoUserVO user = null;
            R<EmoUserVO> result = emoUserService.getInfoByUserId(vo.getUserId(), SecurityConstants.INNER);
            if (StringUtils.isNotNull(result) && StringUtils.isNotNull(result.getData())){
                user = result.getData();
            }

            if (null != user) {
                Double happyScore = user.getHappinessScore().doubleValue();
                Double happyScoreMax = getHappyScoreMax(vo);
                Double happyScoreMin = getHappyScoreMin(vo);
                communicateModelScore = getCommModelScore(happyScore, happyScoreMax, happyScoreMin, communicateModelScore);
            }


            userModelScore = getUserModel(vo.getUserId(),vo.getRtype(), communicateModelScore, communicateModelScore, communicateModelScore, communicateModelScore, 0.0, 0.0);

        }


//        ------------------------------------------考勤---------------------------------------------------------------

        Double happyUserHcmQxPtdaModelScore = 0.0;
        if (ObjectUtil.isNotNull(vo.getUserHcmQxPtData())) {

            happyUserHcmQxPtdaModelScore = gethappyUserHcmQxPtdaModelScore(vo);

            EmoUserVO user = null;
            R<EmoUserVO> result = emoUserService.getInfoByUserId(vo.getUserId(), SecurityConstants.INNER);
            if (StringUtils.isNotNull(result) && StringUtils.isNotNull(result.getData())){
                user = result.getData();
            }
            if (null != user) {
                Double happyScore = user.getHappinessScore().doubleValue();
                Double happyScoreMax = getHappyScoreMax(vo);
                Double happyScoreMin = getHappyScoreMin(vo);
                happyUserHcmQxPtdaModelScore = gethappyUserHcmQxPtdaScore(happyScore, happyScoreMax, happyScoreMin, happyUserHcmQxPtdaModelScore);
            }
            userModelScore = getUserModel(vo.getUserId(),vo.getRtype(), happyUserHcmQxPtdaModelScore, 0.0, happyUserHcmQxPtdaModelScore, happyUserHcmQxPtdaModelScore, 0.0, 0.0);


        }
        //-------------------------------------------------------------------------------------------------------------

        happyDTO.setModelScore(userModelScore);
        return happyDTO;


    }


    @Override
    public AjaxResult updateUserModelByUserId(Long userId) {
        ArrayList<String> riskType = new ArrayList<>();
        riskType.add(HappyConstants.EMO_USER_RTYPE_ADVICE);
        riskType.add(HappyConstants.EMO_USER_RTYPE_APPRAISE);
        riskType.add(HappyConstants.EMO_USER_RTYPE_AI);
        riskType.add(HappyConstants.EMO_USER_RTYPE_SURVEY);
        riskType.add(HappyConstants.EMO_USER_RTYPE_TRAINING);
        riskType.stream().forEach(risktype -> {
            try {
                HappyDTO happyDTO = new HappyDTO();
                if (risktype.equals(HappyConstants.EMO_USER_RTYPE_ADVICE)) {
                    HappyVO happyVO = new HappyVO().setUserId(userId).setRtype(risktype).setAdvice(new HappyAdvice());
                    HappyDTO happinessScores = hScoresService.getHappinessScores(happyVO);
                    happyDTO.setModelScore(happinessScores.getModelScore());
                }
                if (risktype.equals(HappyConstants.EMO_USER_RTYPE_APPRAISE)) {
                    HappyVO happyVO = new HappyVO().setUserId(userId).setRtype(risktype).setApprise(new HappyApprise());
                    HappyDTO happinessScores = hScoresService.getHappinessScores(happyVO);
                    happyDTO.setModelScore(happinessScores.getModelScore());
                }
                if (risktype.equals(HappyConstants.EMO_USER_RTYPE_SURVEY)) {
                    HappyVO happyVO = new HappyVO().setUserId(userId).setRtype(risktype).setSurvey(new HappySurvey());
                    HappyDTO happinessScores = hScoresService.getHappinessScores(happyVO);
                    happyDTO.setModelScore(happinessScores.getModelScore());
                }
                if (risktype.equals(HappyConstants.EMO_USER_RTYPE_TRAINING)) {
                    HappyVO happyVO = new HappyVO().setUserId(userId).setRtype(risktype).setTraining(new HappyTraining());
                    HappyDTO happinessScores = hScoresService.getHappinessScores(happyVO);
                    happyDTO.setModelScore(happinessScores.getModelScore());
                }
                if (risktype.equals(HappyConstants.EMO_USER_RTYPE_AI)) {
                    HappyVO happyVO = new HappyVO().setUserId(userId).setRtype(risktype).setAi(new HappyAiType());
                    HappyDTO happinessScores = hScoresService.getHappinessScores(happyVO);
                    happyDTO.setModelScore(happinessScores.getModelScore());
                }

                userModelScoreService.updateUserModelScore(happyDTO.getModelScore(),SecurityConstants.INNER);


            } catch (Exception e) {
                e.printStackTrace();
            }
        });


        return AjaxResult.success();
    }

    @Override
    public Double queryEmoUserModel(Long userId) {
        List<UserModelScore> userModelScoreList = new ArrayList<>();
        R<List<UserModelScore>> result = userModelScoreService.getuserModelScoreList(userId, SecurityConstants.INNER);
        if (StringUtils.isNotNull(result) && StringUtils.isNotNull(result.getData())){
            userModelScoreList = result.getData();
        }

        Map<String, BigDecimal> typeTotalScore = userModelScoreList.stream().collect(Collectors.toMap(UserModelScore::getRtype, UserModelScore::getTotalScore));

        BigDecimal sumOfValues = typeTotalScore.values().stream()
                .reduce(BigDecimal.ZERO, BigDecimal::add);


        return sumOfValues.doubleValue();

    }

    @Override
    public void updateHscore(Long userId, Integer hscore) {
        emoUserService.updateHappinessScoreByUserId(userId,hscore,SecurityConstants.INNER);
    }


    private Double gethappyUserHcmQxPtdaModelScore(HappyVO vo) {

        Double modelScore = 0.0;
        Integer addScore = -(10 - (int) (Math.random() * 6));//异常每次  -[5,10]


        UserModelScore one = null;
        R<UserModelScore> result = userModelScoreService.getUserModelScoreByUserIdAndType(vo.getUserId(), vo.getRtype(), SecurityConstants.INNER);
        if (StringUtils.isNotNull(result) && StringUtils.isNotNull(result.getData())){
            one = result.getData();
        }
        if (null != one) {
            modelScore = one.getRecordScore().doubleValue();
            modelScore += addScore;
            return modelScore;
        }


        return addScore.doubleValue();
    }

    private Double gethappyUserHcmQxPtdaScore(Double happyScore, Double happyMax, Double happyMin, double modelScore) {
        Double score = modelScore;
        if (happyScore + modelScore >= happyMax) {
            score = happyMax - happyScore;
        }
        if (happyScore + modelScore < happyMin) {
            score = happyMin - happyScore;

        }
        return score;
    }


    private Double getCommunicateModelScore(HappyVO vo) {
        Double communicateModelScore = 0.0;

        if (ObjectUtil.isNotNull(vo.getCommunicate().getResultAddScore()) && ObjectUtil.isNotNull(vo.getCommunicate().getDefultAddScore())) {
            communicateModelScore += vo.getCommunicate().getResultAddScore() + vo.getCommunicate().getDefultAddScore();
        }


        return communicateModelScore;
    }

    @NotNull
    private UserModelScoreVO getAdviceModelScore(HappyVO vo) {
        Double adviceBaseScore = getModelBaseScore(vo.getBasePercent());
        Double adviceRecordScore = 0.0;
        Double addScore = 0.0;

        UserModelScore one = null;
        R<UserModelScore> result = userModelScoreService.getUserModelScoreByUserIdAndType(vo.getUserId(), vo.getRtype(), SecurityConstants.INNER);
        if (StringUtils.isNotNull(result) && StringUtils.isNotNull(result.getData())){
            one = result.getData();
        }
        if (null != one) {
            adviceRecordScore = one.getRecordScore().doubleValue();//之前的记录分
        }

        Double adviceModelScore = adviceBaseScore + adviceRecordScore;
        if (ObjectUtil.isNotNull(vo.getAdvice().getStar())) {//有点赞
            addScore = AdviceEnum.getScore(vo.getAdvice().getStar());//点赞分
        }
        if (ObjectUtil.isNotNull(adviceRecordScore)) {//原始有分
            adviceRecordScore = adviceRecordScore + addScore;//累加点赞
        }

        if (ObjectUtil.isNotNull(vo.getAdvice().getOperCount())) {//有指派
            addScore = vo.getAdvice().getOperCount() * config.getAdviceOperValue();//一次是三分
            adviceRecordScore += addScore;//累加
        }

        adviceModelScore += addScore;
        adviceModelScore = getModelScoreMinAndMax(adviceModelScore, vo.getBasePercent());//判断模块最大最小值


        UserModelScoreVO userModelScore = getUserModel(vo.getUserId(),vo.getRtype(), adviceModelScore, adviceBaseScore, adviceRecordScore, addScore, 0.0, 0.0);

        return userModelScore;
    }

    @NotNull
    private UserModelScoreVO getTrainingModelScore(HappyVO vo) {

//        UserModelScoreVO userModelScore = new UserModelScoreVO();
        Double trainingBaseScore = getModelBaseScore(vo.getBasePercent());
        Double baseRecordScore = getModelRecordScore(vo.getBasePercent());
        Double addScore = 0.0;
        Double recordScore = 0.0;
        Double trainingModelScore = trainingBaseScore;


        UserModelScore one = null;
        R<UserModelScore> result = userModelScoreService.getUserModelScoreByUserIdAndType(vo.getUserId(), vo.getRtype(), SecurityConstants.INNER);
        if (StringUtils.isNotNull(result) && StringUtils.isNotNull(result.getData())){
            one = result.getData();
        }

        if (null != one) {//model有记录
            recordScore = one.getRecordScore().doubleValue();//有旧记录

            if (ObjectUtil.isNotNull(vo.getTraining().getNotJoin())) {
                addScore = -(vo.getTraining().getNotJoin() * baseRecordScore * config.getTrainingNotJoinCoefficient());
                recordScore -= addScore;
            }
            if (ObjectUtil.isNotNull(vo.getTraining().getJoin())) {
                addScore = (vo.getTraining().getJoin() * baseRecordScore * config.getTrainingJoinCoefficient());
                recordScore += addScore;
            }
            trainingModelScore = trainingBaseScore + recordScore;
        } else {
            if (ObjectUtil.isNotNull(vo.getTraining().getNotJoin())) {
                addScore = -(vo.getTraining().getNotJoin() * baseRecordScore * config.getTrainingNotJoinCoefficient());
//            trainingModelScore = trainingModelScore - (vo.getTraining().getNotJoin() * trainingRecordScore * config.getTrainingNotJoinCoefficient());
                trainingModelScore -= addScore;
            }
            if (ObjectUtil.isNotNull(vo.getTraining().getJoin())) {
                addScore = (vo.getTraining().getJoin() * baseRecordScore * config.getTrainingJoinCoefficient());
                trainingModelScore += addScore;
            }

        }

        UserModelScoreVO userModelScore = getUserModel(vo.getUserId(),vo.getRtype(), getModelScoreMinAndMax(trainingModelScore, vo.getBasePercent()), trainingBaseScore, recordScore, addScore, getModelRecordScore(vo.getBasePercent()), 0.0);


        return userModelScore;
    }

    @NotNull
    private UserModelScoreVO getSurveyModelScore(HappyVO vo) {
        Double surveyBaseScore = getModelBaseScore(vo.getBasePercent());//基础
        Double surveyRecordScore = getModelRecordScore(vo.getBasePercent());//基础记录分
        Double recordScore = 0.0;//记录分
        Double addScore = 0.0;

        UserModelScore one = null;
        R<UserModelScore> result = userModelScoreService.getUserModelScoreByUserIdAndType(vo.getUserId(), vo.getRtype(), SecurityConstants.INNER);
        if (StringUtils.isNotNull(result) && StringUtils.isNotNull(result.getData())){
            one = result.getData();
        }
//        UserModelScoreVO userModelScore = new UserModelScoreVO();

        if (ObjectUtil.isNotNull(vo.getSurvey().getGrade()) && vo.getSurvey().getGrade().equals(1)) {
            addScore = -surveyRecordScore * config.getTheSurveyRecordIsBad();
        }
        if (ObjectUtil.isNotNull(vo.getSurvey().getGrade()) && !vo.getSurvey().getGrade().equals(1)) {
            addScore = +surveyRecordScore * (vo.getSurvey().getGrade() * config.getTheSurveyRecordResultIsOthers());
        }

        Double surveyModelScore = surveyBaseScore + addScore;

        if (ObjectUtil.isNotNull(vo.getSurvey().getNotJoin())) {
            // 未参加减分
            addScore = -vo.getSurvey().getNotJoin() * surveyBaseScore * config.getTheSurveyNotJoin();
            surveyModelScore += addScore;
        }
        if (null != one) {
            recordScore = one.getRecordScore().doubleValue() + addScore;
            surveyModelScore = surveyBaseScore + recordScore;
        }

        double totalScore = getModelScoreMinAndMax(surveyModelScore, vo.getBasePercent());
        Double baseRecordScore = getModelRecordScore(vo.getBasePercent());
        UserModelScoreVO userModelScore = getUserModel(vo.getUserId(),vo.getRtype(), totalScore, surveyBaseScore, recordScore, addScore, baseRecordScore, 0.0);

        return userModelScore;
    }

    @NotNull
    private UserModelScoreVO getAppriseModelModel(HappyVO vo) {

        // 评价模块基础分数
        Double appriseBaseScore = getModelBaseScore(vo.getBasePercent());
        Double baseRecordScore = 0.0;
        Double appriseRecordScore = 0.0;//没有记录就是0分
        Double appriseAddScore = 0.0;//评价记录增加分数

        UserModelScore one = null;
        R<UserModelScore> result = userModelScoreService.getUserModelScoreByUserIdAndType(vo.getUserId(), vo.getRtype(), SecurityConstants.INNER);
        if (StringUtils.isNotNull(result) && StringUtils.isNotNull(result.getData())){
            one = result.getData();
        }
        if (null != one) {
            vo.getApprise().setRecordsScore(one.getRecordScore().doubleValue());
            appriseRecordScore = one.getRecordScore().doubleValue();
        }

        //计算该条记录的得分
        if (null != vo.getApprise().getLikeCount()) {//有记录
            appriseAddScore = getAppriseAddScore(vo.getApprise().getLikeCount(), vo.getBasePercent());
            // 一条记录得分最大值
            Double theMaximumScoreForOneRecord = config.getMaxScore() * vo.getBasePercent() * config.getTheMaximumScoreForOneRecordCoefficient();
            if (null != appriseAddScore && appriseAddScore >= theMaximumScoreForOneRecord) {
                appriseAddScore = theMaximumScoreForOneRecord;
            }
        }
        appriseRecordScore = appriseAddScore;//之前没有记录分

        if (null != vo.getApprise().getRecordsScore()) {//之前有记录分
            //记录分
            appriseRecordScore += appriseAddScore;//之前的记录分加上这条的
        }


        Double appriseModelScore = appriseBaseScore + appriseRecordScore;

        double totalScore = getModelScoreMinAndMax(appriseModelScore, vo.getBasePercent());

        UserModelScoreVO userModelScore = getUserModel(vo.getUserId(),vo.getRtype(), totalScore, appriseBaseScore, appriseRecordScore, appriseAddScore, 0.0, 0.0);

        return userModelScore;
    }

    private UserModelScoreVO getAiModelScore(HappyVO vo) {


        Double baseScore = getModelBaseScore(vo.getBasePercent());
        Double baseRecordScore = getModelRecordScore(vo.getBasePercent());
        Double recordScore = 0.0;
        Double aiModelScore = baseScore + recordScore;//初始值
        Double aiAddScore = 0.0;//每次增加
        Double aiImageScore = 0.0;//图片分

        String aiType = vo.getAi().getAiType();
        if (!Objects.isNull(aiType)) {
            aiAddScore = AiEnum.getScore(aiType);
        }
        UserModelScore one = null;
        R<UserModelScore> result = userModelScoreService.getUserModelScoreByUserIdAndType(vo.getUserId(), vo.getRtype(), SecurityConstants.INNER);
        if (StringUtils.isNotNull(result) && StringUtils.isNotNull(result.getData())){
            one = result.getData();
        }
        if (null != one) {//有记录
            recordScore = one.getRecordScore().doubleValue() + aiAddScore;
            aiImageScore = one.getAiImageTotalScore() + aiAddScore;
        } else {
            recordScore += aiAddScore;
            aiImageScore = aiAddScore;
        }
        aiModelScore = baseScore + recordScore;

        if (null != aiImageScore) {
            //如果图片总得分值大于aiRecordScore，那么模块实际得分为
            aiModelScore = getAiModelScoreByImageScore(baseScore, baseRecordScore, aiImageScore);
        }


        UserModelScoreVO userModelScore = getUserModel(vo.getUserId(),HappyConstants.EMO_USER_RTYPE_AI, getModelScoreMinAndMax(aiModelScore, vo.getBasePercent()), baseScore, recordScore, aiAddScore, getModelRecordScore(vo.getBasePercent()), aiImageScore);


        return userModelScore;
    }


    private Double getAiModelScoreByImageScore(Double aiBaseScore, Double recordScore, Double aiImageScore) {
        Double aiModelScore;
        Double abs = Math.abs(aiImageScore);
        if (aiImageScore > recordScore) {
            //如果图片总得分值大于aiRecordScore，那么模块实际得分为：
            aiModelScore = aiBaseScore + (recordScore * (aiImageScore / (recordScore + abs)) * config.getAiCoefficient());
        } else {
            aiModelScore = aiBaseScore + (aiImageScore * (recordScore / (recordScore + abs)) * config.getAiCoefficient());
        }
        return aiModelScore;
    }

    private Double getModelRecordScore(Double basePercent) {
        return (config.getMaxScore() * basePercent) * config.getModuleRecordsCoefficient();
    }

    private Double getModelBaseScore(Double basePercent) {
        return (config.getMaxScore() * basePercent) * config.getModuleBaseScoreCoefficient();
    }

    private Double getAppriseAddScore(Integer appriseLikeCount, Double appriseBasePercent) {
        Double appriseAddScore = 0.0;

        appriseAddScore = AppriseEnum.getB(appriseLikeCount);
        appriseAddScore = appriseAddScore * (1 - appriseBasePercent) * config.getAppriseAddScoreCoefficient();//系数 Coefficient
        return appriseAddScore;

    }


    private double getModelScoreMinAndMax(double modelScore, double base_percent) {
        double model_maxScore = (config.getMaxScore() * base_percent) * config.getMax();// 模块得分最大值
        double model_minScore = (config.getMaxScore() * base_percent) * config.getMini();//模块得分最min
        if (modelScore > model_maxScore) {
            modelScore = model_maxScore;
        }
        if (modelScore < model_minScore) {
            modelScore = model_minScore;
        }
        return modelScore;
    }

    /**
     * 得到最大值
     *
     * @param vo
     * @return
     */
    private Double getHappyScoreMax(HappyVO vo) {

        return config.getMaxScore() * config.getMax();

    }

    /**
     * 得到最小值
     *
     * @param vo
     * @return
     */
    private Double getHappyScoreMin(HappyVO vo) {

        return config.getMaxScore() * config.getMini();

    }

    /**
     * 判断最终得分是不是在合理区间内
     */
    private Double getCommModelScore(Double happyScore, Double happyMax, Double happyMin, Double modelScore) {
        Double score = modelScore;
        if (happyScore + modelScore >= happyMax) {
            score = happyMax - happyScore;
        }
        if (happyScore + modelScore < happyMin) {
            score = happyMin - happyScore;

        }
        return score;
    }

    /**
     * 获得各个模块权重
     */
    private void getRisk(HappyVO vo) {
        Assert.isTrue(StringUtils.isNotBlank(vo.getRtype()), "invalid.riskType");
        RiskVO risk = null;
        R<RiskVO> result = riskService.getByRiskType(vo.getRtype(), SecurityConstants.INNER);
        if (StringUtils.isNotNull(result) && StringUtils.isNotNull(result.getData())){
            risk = result.getData();
        }
        if (null != risk) {
            vo.setBasePercent(risk.getWeight().doubleValue());
        } else {
            new BaseException("err");
        }
    }

    private UserModelScoreVO getUserModel(Long userId, String rType, Double totalScore, Double baseScore, Double recordScore, Double addScore, Double baseRecordScore, Double aiImageTotalScore) {
        UserModelScoreVO userModelScore = new UserModelScoreVO();

        userModelScore.setUserId(userId);
        userModelScore.setRType(rType);

        userModelScore.setTotalScore(totalScore);

        userModelScore.setBaseScore(baseScore);

        userModelScore.setRecordScore(recordScore);

        userModelScore.setAddScore(addScore);

        userModelScore.setBaseRecordScore(baseRecordScore);

        userModelScore.setAiImageTotalScore(aiImageTotalScore);

        return userModelScore;

    }
}

